import request from '@/utils/request.js'

// 获取指定日期的时间段数据
export function getTimeSlotsByDate(date) {
  return request.get('/timeSlots/by-date', {
    params: { date }
  })
}

// 预约时间段
export function bookTimeSlot(bookingData) {
  return request.post('/bookings/book', bookingData)
}

// 获取可预约日期列表
export function getAvailableDates() {
  return request.get('/timeSlots/available-dates')
}

// 检查用户是否已预约
export function checkUserBooking(userToken, contactPhone) {
  return request.get('/bookings/check-user', {
    params: { 
      userToken,
      contactPhone 
    }
  })
}

// 根据预约编号查询预约信息
export function getBookingByNumber(bookingNumber) {
  return request.get(`/bookings/booking-number/${bookingNumber}`)
}

// 获取用户的预约记录列表
export function getUserBookings(userToken) {
  return request.get('/bookings/user-bookings', {
    params: { userToken }
  })
}

export default {
  getTimeSlotsByDate,
  bookTimeSlot,
  getAvailableDates,
  checkUserBooking,
  getBookingByNumber,
  getUserBookings
} 